package org.lwj.logger.http;

/**
 * 抽象头部类型
 * 
 * @author liwenjian
 *
 */
public abstract class AbstractHttpHeadType<T> implements HttpHeadType {

	public abstract Class<T> headType();

	public abstract boolean addHeader(T head, String key, String value);

	public boolean addHead(Object head, String key, String value) {
		if (head != null) {
			Class<T> typeClass = headType();
			if (typeClass.isAssignableFrom(head.getClass())) {
				@SuppressWarnings("unchecked")
				T t = (T) head;
				return addHeader(t, key, value);
			}
		}
		return false;
	}

}
